'use strict';

module.exports = app => {
    const { Sequelize, model } = app

    const Model = model.define('minaSpreadCode', {
        id:{
            type: Sequelize.STRING.BINARY,
            defaultValue: Sequelize.UUIDV1,
            primaryKey: true
        },
        userName:{
            type: Sequelize.STRING(20),
            allowNull: false,
        },
        phone:{
            type: Sequelize.STRING(30),
        },
        value:{
            type: Sequelize.STRING(10),
            allowNull: false,
            unique: true
        },
    }, {
        freezeTableName: true,
        tableName: 'mina_spread_code',
    })

    Model.associate = function() {
        model.MinaSpreadCode.belongsTo(model.Corp)
        model.Corp.hasOne(model.MinaSpreadCode)
    }

    return Model
}